package stu.sup.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import stu.sup.entity.Coupon;
import stu.sup.mapper.CouponMapper;
import stu.sup.service.ICouponService;

/**
 * Created by HUAWEI on 2020/6/26.
 */
@Service
@Transactional
public class CouponServiceImpl implements ICouponService{
    @Autowired
    CouponMapper couponMapper;
    @Override
    public boolean addCoupon(Coupon coupon) {
        int count=0;
        count=couponMapper.insert(coupon);
        return 0==count?false:true;
    }

    @Override
    public boolean delateCoupon(int couponId) {
        int count=0;
        count=couponMapper.deleteByPrimaryKey(couponId);
        return 0==count?false:true;
    }

    @Override
    public int updataCoupon(Coupon coupon) {
        int count=couponMapper.updateByPrimaryKeySelective(coupon);
        return count;
    }

    @Override
    public Coupon findCoupon(int couponId) {
        Coupon coupon=new Coupon();
        coupon=couponMapper.selectByPrimaryKey(couponId);
        return coupon;
    }
}
